package se.perp.c4.ui;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Window;
import javax.swing.BorderFactory;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import se.perp.c4.model.Card;

public class CardDisplayDialog extends JDialog {


    public CardDisplayDialog(Window owner, String title, Card card) {
        super(owner);

        setModalityType(ModalityType.MODELESS);
        setTitle(title);
        setDefaultCloseOperation(DISPOSE_ON_CLOSE);

        JPanel mainPanel = new JPanel(new BorderLayout());
        mainPanel.setBackground(ColorSet.BOARD_BG);
        mainPanel.setBorder(BorderFactory.createRaisedBevelBorder());

        CardImagePanel imagePanel = new CardImagePanel(card);
        imagePanel.setBackground(mainPanel.getBackground());
        imagePanel.setHoverSensitive(false);

        JPanel centerPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
        centerPanel.add(imagePanel);
        centerPanel.setBackground(mainPanel.getBackground());

        JLabel label = new JLabel(title, SwingConstants.CENTER);
        label.setFont(FontSet.CARDPICKER_CAPTION);
        label.setBackground(mainPanel.getBackground());
        label.setForeground(ColorSet.contrastingColor(label.getBackground()));

        mainPanel.add(label, BorderLayout.NORTH);
        mainPanel.add(centerPanel, BorderLayout.CENTER);
        add(mainPanel);
        pack();
    }
}
